﻿@model PlmTestLogViewModel
@{
    Layout = null;
    ViewBag.Title = "检测日志列表";
    var num = 1;
}

<div class="page" style="border-top: 1px solid #b8d0d6;" layouth="1">
    @using (Html.BeginForm("SplitPage", "PlmTestLog", null, FormMethod.Post, new { id = "pagerForm", onsubmit = "return navTabSearch(this);" }))
    {
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@(ViewBag.numPerPage)" />
        <ul class="searchBar">
            <li><span>检测单位：</span>
                <input type="text" name="Tl_SupervisorName" value="@(ViewBag.Tl_SupervisorName)" />
            </li>
            <li><span>编号：</span>
                <input type="text" name="Tl_SupervisionNumber" value="@(ViewBag.Tl_SupervisionNumber)" />
            </li>
            <li><span>记录日期：</span>
                <input type="text" name="Tl_RecordDate" class="date" value="@(ViewBag.Tl_RecordDate)" />
            </li>
            <li><span>标段：</span>
                <input type="text" name="Tl_ContractNumber" value="@(ViewBag.Tl_ContractNumber)" />
            </li>
            <li>
                <button type="submit" class="btn btn-success btn-xs">
                    搜索</button>
            </li>
        </ul>
    }
    <div class="panelBar" style="border-top: none;">
        <ul class="toolBar">
            <li>
                @Html.PermissionButton("PersonnelLog.PlmTestLog.Create", "PersonnelLog_PlmTestLog_TestLogAdd",
                    Url.Action("TestLogAdd", "PlmTestLog", new { target = "add" }),
                    "添加",
                    new Dictionary<string, object>
                    {
                        {"class","add"} ,{"rel","jcrz_add"} ,{"mask","true"},{"target","dialog"},{"width","690"},{"height","560"}
                    })
            </li>
            <li>
                @Html.PermissionButton("PersonnelLog.PlmTestLog.Delete", "PersonnelLog_PlmTestLog_TestLogDelete",
                    Url.Action("TestLogDelete", "PlmTestLog", new { id = "{sid_user}" }),
                    "删除",
                    new Dictionary<string, object>
                    {
                        {"class","delete"} ,{"mask","true"} ,{"target","ajaxTodo"},{"title","确定要删除该条记录吗?"}
                    })
            </li>
            <li>
                @Html.PermissionButton("PersonnelLog.PlmTestLog.Edit", "PersonnelLog_PlmTestLog_TestLogAdd",
                    Url.Action("TestLogAdd", "PlmTestLog", new { target = "edit", id = "{sid_user}" }),
                    "修改",
                    new Dictionary<string, object>
                    {
                        {"class","edit"}  ,{"rel","jcrz_edit"} ,{"mask","true"},{"target","dialog"},{"width","690"},{"height","560"},{"warn","请选择一条信息"}
                    })
            </li>
            <li>
                @Html.PermissionButton("PersonnelLog.PlmTestLog.Detail", "PersonnelLog_PlmTestLog_TestLogView",
                    Url.Action("TestLogView", "PlmTestLog", new { target = "view", id = "{sid_user}" }),
                    "查看",
                    new Dictionary<string, object>
                    {
                        {"class","detail"}  ,{"rel","jcrz_detail"} ,{"mask","true"},{"target","dialog"},{"width","690"},{"height","560"},{"warn","请选择一条信息"}
                    })
            </li>
            <li>@Html.PermissionButton("PersonnelLog.PlmTestLog.Export", "PersonnelLog_PlmTestLog_TestLogExport",
                    Url.Action("TestLogExport", "PlmTestLog", new { id = "111" }),
                    "导出",
                    new Dictionary<string, object>
                    {
                        {"class","export"} ,{"targetType","navTab"},{"warn","请选择一条信息"}
                    })
            </li>
        </ul>
    </div>
    <table class="table" width="100%" layouth="122">
        <thead>
            <tr>
                <th align="center">
                    序号
                </th>
                <th align="center">
                    检测单位
                </th>
                <th align="center">
                    编号
                </th>
                <th align="center">
                    记录日期
                </th>
                <th align="center">
                    标段
                </th>
                <th align="center">
                    记录人
                </th>
                <th align="center">
                    审核人
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.ThePlmTestlogList)
            {
                <tr target="sid_user" rel="@item.Tl_ID" data-testlog="true">
                    <td>@num
                    </td>
                    <td>@item.Tl_TestUnit
                    </td>
                    <td>@item.Tl_Number
                    </td>
                    <td>@item.Tl_RecordDate.ToString("yyyy-MM-dd")
                    </td>
                    <td>@item.Tl_ContractNumber
                    </td>
                    <td>@item.Tl_RecordUser
                    </td>
                    <td>@item.Tl_AuditMan
                    </td>
                </tr>
                   num++;
            }
        </tbody>
    </table>
    <div class="panelBar" style="border-bottom: none;">
        <div class="pagination" style="margin:0px;float:left; margin-left:35%" targettype="navTab" totalcount="@(ViewBag.totalcount)" numperpage="@(ViewBag.numPerPage)" pagenumshown="10" currentpage="@(ViewBag.pageNum)">
        </div>
        <div class="pages" style="float: right">
            <span>显示</span>
            <select class="comsplitpage" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="10" @(ViewBag.numPerPage == 10 ? "selected='selected'" : "")>10</option>
                <option value="20" @(ViewBag.numPerPage == 20 ? "selected='selected'" : "")>20</option>
                <option value="50" @(ViewBag.numPerPage == 50 ? "selected='selected'" : "")>50</option>
            </select>
            <span>条，共@(ViewBag.pagenumshown)页,@(ViewBag.totalcount)条</span>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#PersonnelLog_PlmTestLog_TestLogExport").bind("click", function () {
            var value = $("#PersonnelLog_PlmTestLog_TestLogExport").attr("href");
            var tag = value.substring(value.lastIndexOf('/') + 1);
            if (tag == "111") {
                alertMsg.warn('请选择一条记录！');
                return false;
            } else {
                return true;
            }
        });
    });
    $.jTableTool.clickRowAction(function ($row) {
        if ($row) {
            var isSpecialityLog = $row.data("testlog");
            if (isSpecialityLog) {
                var $this = $("#PersonnelLog_PlmTestLog_TestLogExport");
                if ($this.length > 0) {
                    var value = $this.attr("href");
                    var tag = value.substring(value.lastIndexOf('/') + 1);
                    //if (tag == "111") {
                    //    var id = $row.attr("rel");
                    //    var href = $this.attr("href").replace("111", id);
                    //    $this.attr("href", href);
                    //}
                    var id = $row.attr("rel");
                    var href = $this.attr("href").replace(tag, id);
                    $this.attr("href", href);

                }
            }
        }
    });
</script>
